﻿Imports System.Data.OleDb

Public Class ThamSoDAO
    Dim sDBName As String = "Database\thietkethoikhoabieu.mdb"

    Public Function LayDanhSachThamSo() As List(Of ThamSoDTO)
        Dim str = "SELECT * FROM ThamSo"
        Dim conn = DataProvider.ConnectDB(sDBName)
        Dim cmd As New OleDbCommand(str, conn)
        Dim reader = cmd.ExecuteReader()
        Dim ds As New List(Of ThamSoDTO)

        While reader.Read()
            Dim ts As New ThamSoDTO
            ts.SoTietToiDa = reader.GetInt32(0)
            ds.Add(ts)
        End While

        conn.Close()
        Return ds
    End Function

    Public Function CapNhatThamSo(ByVal ts As ThamSoDTO) As Integer

        Dim str = String.Format("UPDATE ThamSo SET SoTietToiDa={0}", ts.SoTietToiDa)
        Dim conn = DataProvider.ConnectDB(sDBName)
        Dim cmd As New OleDbCommand(str, conn)
        Dim ketqua = -1
        ketqua = cmd.ExecuteNonQuery()

        conn.Close()
        Return ketqua
    End Function
End Class
